Skip to content

Conversation

@alexandear
Copy link
Contributor

@alexandear alexandear commented Jan 26, 2026

Summary

Rename the pkg/utils package to pkg/mcpresult and pkg/githubapi with clearer function names to resolve a revive.var-naming issue.

Why

The pkg/utils package name is "bad", triggering a revive linter warning. Renaming to pkg/mcpresult and pkg/githubapi makes the purpose explicit and improves code clarity. Function names are simplified from NewToolResultX to NewX to align with Go naming conventions and reduce redundancy.

What changed

  • Created new pkg/mcpresult package with clearer function names: NewText, NewError, NewErrorFromErr, NewResource
  • Created new pkg/githubapi package
  • Updated all files to import and use mcpresult or githubapi directly

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR
    This refactoring renames internal utility functions and packages, not MCP tools.
    Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

@alexandear alexandear requested a review from a team as a code owner January 26, 2026 15:16
Copilot AI review requested due to automatic review settings January 26, 2026 15:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the generic pkg/utils tool-result helpers into a more explicit pkg/mcpresult package, then updates all call sites while keeping a thin deprecated compatibility layer for backwards compatibility.

Changes:

  • Introduces pkg/mcpresult with NewText, NewError, NewErrorFromErr, and NewResource helpers wrapping MCP call-tool results.
  • Converts all existing users in pkg/github and pkg/errors from utils.NewToolResult* to mcpresult.*.
  • Leaves pkg/utils/result.go as a deprecated shim that delegates to mcpresult, preserving the old API surface.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/utils/result.go Turns utils result helpers into a deprecated shim that delegates to mcpresult, maintaining backward-compatible APIs.
pkg/mcpresult/mcpresult.go Adds the new focused mcpresult package implementing the actual result-construction helpers used across the codebase.
pkg/github/server.go Updates the JSON-marshalling helper to use mcpresult for success and error tool results.
pkg/github/security_advisories.go Switches all advisory tools to construct error/success tool results via mcpresult.
pkg/github/secret_scanning.go Routes secret scanning tools’ success and error responses through mcpresult.
pkg/github/search_utils.go Uses mcpresult for search error handling and response marshalling.
pkg/github/search.go Migrates repository/code/user/org search tools to the new mcpresult helpers.
pkg/github/repositories_test.go Adjusts test expectations to use mcpresult.NewError rather than the deprecated utils helpers.
pkg/github/repositories_helper.go Updates repository helper responses (match results and errors) to use mcpresult.
pkg/github/repositories.go Replaces all repository tool result construction (commits, branches, files, tags, releases, stars) with mcpresult calls.
pkg/github/pullrequests.go Refactors pull request tools (read, write, reviews, Copilot review) to use mcpresult for text and error responses.
pkg/github/projects.go Updates projects tools (list/get/update/delete items, fields, discovery helpers) to rely on mcpresult for tool results.
pkg/github/notifications.go Switches notification tools (list, dismiss, mark read, manage subscriptions) to mcpresult helpers.
pkg/github/labels.go Adapts label read/write tools to construct responses via mcpresult.
pkg/github/issues.go Uses mcpresult for all issue-related responses, including lockdown errors, sub-issues, comments, and issue create/update flows.
pkg/github/git.go Changes repository tree tool result construction from utils to mcpresult.
pkg/github/gists.go Migrates gist listing/reading/creating/updating tools to mcpresult.
pkg/github/feature_flags_test.go Updates the test-only HelloWorldTool to use mcpresult in its test assertions.
pkg/github/dynamic_tools.go Uses mcpresult for dynamic toolset enable/list helpers instead of utils.
pkg/github/discussions.go Routes discussion tools (list, get, comments, categories) through mcpresult for text/error handling.
pkg/github/dependabot.go Updates Dependabot alert tools to use mcpresult for results and error wrapping.
pkg/github/context_tools.go Switches context tools (GetMe, teams, team members) to use mcpresult.
pkg/github/code_scanning.go Refactors code scanning alert tools to use mcpresult helpers.
pkg/github/actions.go Systematically replaces all Actions tools’ result construction (runs, jobs, logs, artifacts, reruns, cancellation) with mcpresult.
pkg/errors/error.go Changes GitHub error helpers to construct MCP error results via mcpresult.NewErrorFromErr while preserving existing behavior.

@alexandear alexandear force-pushed the refactor/rename-utils-mcpresult branch 2 times, most recently from 1e7807f to 5076b51 Compare January 26, 2026 15:21
@alexandear alexandear requested a review from Copilot January 26, 2026 15:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

@SamMorrowDrums
Copy link
Collaborator

@alexandear am I missing something? The linting setup in CI doesn't seem to flag this, and if we are making lint fix PRs I would expect that they include enabling rules in CI etc. otherwise there is nothing to prevent regression.

@alexandear alexandear force-pushed the refactor/rename-utils-mcpresult branch from 23b4bc9 to f2deffa Compare February 10, 2026 10:01
@alexandear alexandear changed the title refactor: rename utils to mcpresult to fix revive issue refactor: avoid utils package name to fix revive issue Feb 10, 2026
@alexandear alexandear force-pushed the refactor/rename-utils-mcpresult branch from f2deffa to 4dfcc2c Compare February 10, 2026 10:07
@alexandear
Copy link
Contributor Author

@SamMorrowDrums I have updated the PR and fixed merge conflicts. While it was under review, two more files were added to the utils package - api.go and token.go in #1849. I think we should decide how we want to handle this PR, because utils tends to become a catch-all. Developers often put new code there instead of choosing more specific package names.

utils is a common name that can have everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants